
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>线程只能在任务到达时才启动吗 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>线程只能在任务到达时才启动吗 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">为什么使用线程池（Thread Pool）能够提高线程管理的效率？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">线程池通过在程序启动时预先创建一组线程并让它们处于待处理状态，来复用这些线程处理多个任务。这种方式避免了因任务到达而频繁创建和销毁线程所带来的开销，从而提升了效率。</div>
          </div>
          <div class="card-source">来源: 1. 线程池（Thread Pool）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">固定线程池（Fixed Thread Pool）和缓存线程池（Cached Thread Pool）在线程数量管理上有何根本区别？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">固定线程池创建一个数量固定的线程来处理任务，线程处理完任务后会继续等待新任务。而缓存线程池会根据需求动态创建线程，并且会销毁那些空闲时间超过一定阈值的线程，它会尽可能重用已有线程。</div>
          </div>
          <div class="card-source">来源: 1. 线程池（Thread Pool）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">在线程管理中，“懒加载”和“即时加载”策略各自的优缺点是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">懒加载（Lazy loading）的优点是节省资源，因为它只在实际需要时才创建线程；缺点是可能会引起任务执行的延迟。即时加载（Eager loading）的优点是能减少任务到达时的延迟，因为它在程序启动时就创建好了线程；缺点是如果线程长时间空闲，可能会浪费系统资源。</div>
          </div>
          <div class="card-source">来源: 3. 懒加载与即时加载</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">单线程池（Single Thread Pool）的主要应用场景或能保证什么特性？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">单线程池只有一个线程用于处理任务，其主要特性是能确保所有提交的任务按顺序处理。</div>
          </div>
          <div class="card-source">来源: 1. 线程池（Thread Pool）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">定时任务（Scheduled Tasks）是如何体现“线程并非总在任务到达时才启动”这一观点的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在定时任务调度器（如 ScheduledExecutorService）中，线程会在预定的时间或按固定的间隔被调度并启动，而不是在任务被提交的那一刻。这意味着线程的启动是基于时间表，而非任务的即时到达。</div>
          </div>
          <div class="card-source">来源: 2. 延迟任务和定时任务</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">文档中提到的“独立线程”和“共享线程”模型的主要区别是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">主要区别在于线程的生命周期和复用性。“独立线程”模型是为每个任务都创建一个新的线程，这会导致较高的创建开销。而“共享线程”模型是让多个任务共享一组预先创建的线程，通过复用线程来提高效率并减少资源消耗。</div>
          </div>
          <div class="card-source">来源: 4. 线程的创建与启动</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
